<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2021/3/15
 * Time: 16:02
 */

namespace common\models\video;
use common\models\author\Author;
use common\models\base\BaseModel;
class Video extends BaseModel
{

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%video}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title', 'author_id','video','url','views'], 'required'],
            [['created_at', 'updated_at', 'sorts'], 'integer'],
            [['title', 'url'], 'string', 'max' => 50],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '视频标题',
            'author_id' =>'作者',
            'video' =>'视频文件',
            'url' => '链接',
            'views' => '浏览量',
            'type' => '类型',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
            'sorts' => '排序',
        ];
    }
    public function getAuthor()
    {
        return $this ->hasOne(Author::class,['id'=>'author_id']);
    }
}